package com.ruibang.glass.quality.controller.finish;

import com.ruibang.glass.quality.domain.req.QualityRoughnessReq;
import com.ruibang.glass.quality.entity.QualityRoughness;
import com.ruibang.glass.quality.service.QualityRoughnessService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import com.teaming.cloud.framework2.common.pojo.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


/**
 * <p>
 * 成品粗糙度信息 前端控制器
 * </p>
 *
 * @author wujie
 * @since 2024-03-21
 */
@RestController
@RequestMapping("/api/quality/roughness")
@Api(value="成品粗糙度信息控制器",tags={"成品粗糙度信息接口"})
public class QualityRoughnessController {

    
    @Autowired
    private QualityRoughnessService qualityRoughnessService;

    
    /**
    * 通过id查询
    */
    @GetMapping("/getById/{id}")
    @ApiOperation(value="获取成品粗糙度信息",notes="获取成品粗糙度信息")
    public ResultBody getById(@PathVariable(value = "id") String id){
        return ResultBody.success(qualityRoughnessService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value="新增成品粗糙度信息",notes="新增成品粗糙度信息")
    public ResultBody save(@RequestBody QualityRoughness qualityRoughness){
        qualityRoughnessService.saveInfo(qualityRoughness);
        return ResultBody.success();
    }

    @GetMapping("/deleteById/{id}")
    @ApiOperation(value="通过ID删除成品粗糙度信息",notes="通过ID删除成品粗糙度信息")
    public ResultBody delete(@PathVariable(value = "id") String id){
        qualityRoughnessService.delete(id);
        return ResultBody.success();
    }

    @PostMapping("/update")
    @ApiOperation(value="修改成品粗糙度信息",notes="修改成品粗糙度信息")
    public ResultBody updateById(@RequestBody QualityRoughness qualityRoughness){
        qualityRoughnessService.updateInfo(qualityRoughness);
        return ResultBody.success();
    }

    @PostMapping("/list")
    @ApiOperation(value="非分页列表查询成品粗糙度信息",notes="非分页列表查询成品粗糙度信息")
    public ResultBody list(@RequestBody QualityRoughnessReq qualityRoughness ){
        return ResultBody.success(qualityRoughnessService.queryQualityRoughness(qualityRoughness));
    }


    @PostMapping("/page")
    @ApiOperation(value="分页列表查询成品粗糙度信息",notes="分页列表查询成品粗糙度信息")
    public ResultBody page(@RequestBody PageRequest<QualityRoughnessReq> pageParam){
        return ResultBody.success(qualityRoughnessService.queryPage(pageParam));
    }


    @PostMapping("/importRoughness")
    @ApiOperation(value="导入成品强度信息excel",notes="导入成品强度信息excel")
    public ResultBody<QualityRoughness> importRoughness(@RequestPart("file") MultipartFile file){
        return ResultBody.success(qualityRoughnessService.importRoughness(file));
    }

}
